use"TPV Climate and Terrorism Replication Data" 
*switching to zinb models.  Overdispersion as well as lots of zeroes**
log using climatechangeterrorism2025July3, replace 

*would like to take a look at percent of the country experiencing extreme weather 

*I think the following is the best way to go. Note that the negative marginal effects looks bettern than the positive ones, and the latter should not be too surprising.  

**this version provides a more nuanced via of how conditions change behavior 

*Attacks NO lagattacks included

zinb totalattacksnewwindsor c.lag6absmvavg1yrs  i.cowcode i.month if urban==0, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table1July3, dec(3) excel append ctitle(ruralattacklag6) 
margins, at(lag6absmvavg1yrs=(0.5(.5)3.5)) 
marginsplot 
graph save "Graph" "C:\Users\ross\Downloads\Climate and terrorism 2025\2025 Folder\Figure Rural Attack Graph July 3.gph" 
margins, dydx(lag6absmvavg1yrs) 

zinb totalattacksnewwindsor c.lag6absmvavg1yrs  i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table1July3, dec(3) excel append ctitle(urbanattacklag6) 
margins, at(lag6absmvavg1yrs=(0.5(.5)3.5)) 
marginsplot 
graph save "Graph" "C:\Users\ross\Downloads\Climate and terrorism 2025\2025 Folder\Figure Urban Attack Graph July 3.gph" 
margins, dydx(lag6absmvavg1yrs) 




*See bottom for fatalities***



***Attacks WITH lag included'
zinb totalattacksnewwindsor c.lag6absmvavg1yrs c.lagtotalattacks i.cowcode i.month if urban==0, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table1July3, dec(3) excel append ctitle(ruralattacklag6withlag)
margins, dydx(lag6absmvavg1yrs) 



zinb totalattacksnewwindsor c.lag6absmvavg1yrs c.lagtotalattacks i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table1July3, dec(3) excel append ctitle(urbanattacklag6withlag)
margins, dydx(lag6absmvavg1yrs) 






**** Now here are models using alternative measures of absspei = at 12 month weighted, 3 month, and just the lag. Here we want to show how the coefficients change in magnitude with the time taken into account. The ides is to depict how it takes time for groups to adapt 12 months weighted average, compared to three month, compared to one month. So we create three columns compairng attacks for rural and then for urban,  

*begin by reproducing the original attack one and then add columns for the other two. Start with rural and then do urban. 


**Not including lagattacks***
**Here is rural at 6 months lag and one month lag***

zinb totalattacksnewwindsor c.lag6absmvavg1yrs i.cowcode i.month if urban==0., inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table2July3, dec(3) excel append ctitle(RuralAttack6monthlag) 


zinb totalattacksnewwindsor c.absmvavg1yrspei  i.cowcode i.month if urban==0, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table2July3, dec(3) excel append ctitle(RuralAttackOnemonthlag) 
 


*now do the urban. This difference is especially clear becasue it depicts the movement of groups 

zinb totalattacksnewwindsor c.lag6absmvavg1yrs  i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table2July3, dec(3) excel append ctitle(Urbanattack6monthlag) 



zinb totalattacksnewwindsor c.absmvavg1yrspei  i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table2July3, dec(3) excel append ctitle(UrbanAttackOnemonthlag) 



 
********Fatalities************

**moving fatalities down to the bottom.  It has estimation probems***  
*First without lagfatalities**

zinb totalfatalitiesnew c.lag6absmvavg1yrs   i.cowcode i.month if urban==0, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table3July3, dec(3) excel append ctitle(ruralfatallag6) 
margins, dydx(lag6absmvavg1yrs) 

zinb totalfatalitiesnew c.lag6absmvavg1yrs   i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table3July3, dec(3) excel append ctitle(urbanfatallag6) 
margins, dydx(lag6absmvavg1yrs) 


*now for fatalities WITH lag.  

zinb totalfatalitiesnew c.lag6absmvavg1yrs c.lagtotalfatalitiesnew i.cowcode i.month if urban==0, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table3July3, dec(3) excel append ctitle(ruralfatallag6withlag) 
margins, dydx(lag6absmvavg1yrs) 


zinb totalfatalitiesnew c.lag6absmvavg1yrs c.lagtotalfatalitiesnew i.cowcode i.month if urban==1, inflate(c.ndvi_minmew) cluster(gid)
outreg2 using climateterrorism2025Table3July3, dec(3) excel append ctitle(urbanfatallag6withlag) 
margins, dydx(lag6absmvavg1yrs) 



 